import axiosHttp from "../../http"
/*
 这是登录有关的接口
*/

// 检测登录成功
function loginsuess() {
  return axiosHttp({
    url: "/users/loginsuccess",
    method: "get",
  }) //这里的  '/login'  是具体的接口后面的名称  例如:http://127.0.0.1/api/login
}

// 发送验证码
async function sendMessageCode(data) {
  return await axiosHttp({
    url: "/users/code",
    method: "post",
    data,
  }).then((res) => {
    return res
  })
}

// 短信登录
async function login(data) {
  return await axiosHttp({
    url: "/users/messagelogin",
    method: "post",
    data,
  }).then((res) => {
    return res
  })
}

// 密码登录
async function passwordLogin(data) {
  return await axiosHttp({
    url: "/users/passwordLogin",
    method: "post",
    data,
  }).then((res) => {
    return res
  })
}

// 账号注册
async function register(data) {
  return await axiosHttp({
    url: "/users/register",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

// 忘记密码
async function forgetPassword(data) {
  return await axiosHttp({
    url: "/users/forgetPassword",
    method: "post",
    data,
  }).then((res) => {
    // console.log(res)
    return res
  })
}

export default {
  login,
  register,
  sendMessageCode,
  loginsuess,
  passwordLogin,
  forgetPassword,
}
